@extends('public')

@section('link')
    <link rel="stylesheet" href="/css/game_details.css">
@endsection

@section('module' , 'Game')

@section('content')
    <div class="warp">
        <div class="content">
            <div class="top">
                <p>{{$data->title}}</p>
                <div class="description">
                    <p>Description</p>
                    <p>{{$data->description}}</p>
                </div>
                <div class="information">
                    <ul>
                        <li>Slug : {{$data->slug}}</li>
                        <li>scoreCount : {{$data->scoreCount}}</li>
                        <li>Author : {{$data->autor->username}}</li>
                        <li>gamePath : /game/{{$data->slug}}</li>
                        <li>create in : {{$data->created_at}}</li>
                        @if($data->is_ban == null)
                            <li><form action="/Module_C/gameDel" method="post"><input type="hidden" name="id" value="{{$data->id}}"><input type="submit" value="Delete"> @csrf @method('DELETE')</form></li>
                        @endif
                    </ul>
                </div>
            </div>
            <div class="both"></div>
            <div class="bottom">
                <div class="top">
                    <p>Game Score</p>
                    <form action="/Module_C/scoreAllDel" method="post">
                        <input type="hidden" name="id" value="{{$data->id}}">
                        @csrf
                        @method('DELETE')
                        <input type="submit" value="Resetting Score">
                    </form>
                </div>
                <ul>
                    @foreach($data->score as $value)
                        @if(count($value->scores))
                            <li>
                                <p class="userName">{{$value->username}}</p>
                                <form action="/Module_C/scoreUserAllDel" method="post">
                                    @csrf
                                    @method('DELETE')
                                    <input type="hidden" value="{{$data->id}}" name="gameId">
                                    <input type="hidden" value="{{$value->id}}" name="userId">
                                    <input type="submit" value="Delete All" class="all">
                                </form>
                            </li>
                            @foreach($value->scores as $scores)
                                <li>
                                    <p class="score">Score : {{$scores->score}}</p>
                                    <p>create in : {{$scores->created_at}}</p>
                                    <form action="/Module_C/scoreUserDel" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <input type="hidden" value="{{$scores->id}}" name="id">
                                        <input type="submit" value="Delete">
                                    </form>
                                </li>
                            @endforeach
                        @endif
                    @endforeach
                </ul>
            </div>
        </div>
    </div>
@endsection
